package com.tgjs.sphoto.request;

import android.content.Context;
import android.os.Handler;

import com.tgjs.sphoto.constant.ConstantValues;

import org.json.JSONObject;
import java.util.HashMap;
import java.util.TreeMap;

/**
 * 作者：wzh
 * 创建时间：2018/2/10 15:39
 * CashLoanSales
 */

public class Api {
    private HttpRequest mHttpRequest;
    private Handler mHandler;
    private Context context;

    public Api(Handler handler, Context context) {
        mHttpRequest = new HttpRequest(handler, context);
        this.mHandler = handler;
    }

    public void getUPhotos(int what,String page){
        String url = ConstantValues.IMAGE_URL +"&page="+page;
        mHttpRequest.getDataString(url,what,true,"");
    }

    public void getUPhotosDetail(int what,String id){
        String url = ConstantValues.IMAGEDETAIL_URL + id +"?client_id="+ConstantValues.ACCESS_KEY;
        mHttpRequest.getDataString(url,what,false,"");
    }

    /**
     * 判断红包是否可以领取
     */
    public void getAccountLogred(int what, String user_id){
        String url = ConstantValues.BASE_URL + "/frontend/getAccountLogred";
        TreeMap<String,String> paramsTreeMap = new TreeMap<>();
        HashMap<String, String> params = new HashMap<>();
        params.put("user_id",user_id);
        JSONObject jsonObject = new JSONObject(params);
        paramsTreeMap.put("data",jsonObject.toString());
        mHttpRequest.postDataString(url,what,"getAccountLogred",paramsTreeMap,true,"");
    }
    /**
     * 领取红包
     */
    public void getReceiveRed(int what, String user_id, String money){
        String url = ConstantValues.BASE_URL + "/frontend/getRedusdt";
        TreeMap<String,String> paramsTreeMap = new TreeMap<>();
        HashMap<String, String> params = new HashMap<>();
        params.put("user_id",user_id);
        params.put("money",money);
        JSONObject jsonObject = new JSONObject(params);
        paramsTreeMap.put("data",jsonObject.toString());
        mHttpRequest.postDataString(url,what,"getAccountLogred",paramsTreeMap,true,"");
    }
    /**
     *获取邀请人列表
     */
    public void getInviterList(int what, String user_id){
        String url = ConstantValues.BASE_URL + "/frontend/inviterList";
        TreeMap<String,String> paramsTreeMap = new TreeMap<>();
        HashMap<String, String> params = new HashMap<>();
        params.put("user_id",user_id);
        JSONObject jsonObject = new JSONObject(params);
        paramsTreeMap.put("data",jsonObject.toString());
        mHttpRequest.postDataString(url,what,"getInviterList",paramsTreeMap,true,"");
    }

}
